//
//  FirstTableViewCell.m
//  NewMusic
//
//  Created by chuxinyu123 on 15/11/23.
//  Copyright © 2015年 Going. All rights reserved.
//

#import "FirstTableViewCell.h"

@interface FirstTableViewCell ()


@end
@implementation FirstTableViewCell

- (void)dealloc
{
    [_numberLabel release];
    [_titleImageView release];
    [_titleLabel release];
    [_songerNameLabel release];
    [_songsListenLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self buildLabel];
    }
    return self;
}
- (void)buildLabel
{
    self.numberLabel = [[UILabel alloc] init];
    self.titleLabel = [[UILabel alloc] init];
    self.titleImageView = [[UIImageView alloc] init];
    self.songerNameLabel = [[UILabel alloc] init];
    self.songsListenLabel = [[UILabel alloc] init];
    
    [self.contentView addSubview:_numberLabel];
    [self.contentView addSubview:_titleLabel];
    [self.contentView addSubview:_titleImageView];
    [self.contentView addSubview:_songsListenLabel];
    [self.contentView addSubview:_songerNameLabel];
    
    [_numberLabel release];
    [_titleImageView release];
    [_titleLabel release];
    [_songerNameLabel release];
    [_songsListenLabel release];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.numberLabel.frame = CGRectMake(0, 0, self.frame.size.height, self.frame.size.height);
    self.titleLabel.frame = CGRectMake(_numberLabel.frame.size.width, 10, self.frame.size.width - _numberLabel.frame.size.width, 30);
    self.songsListenLabel.frame = CGRectMake(_titleLabel.frame.origin.x, _titleLabel.frame.size.height + _titleLabel.frame.origin.y, 2, 30);
    self.titleImageView.frame = CGRectMake(_songerNameLabel.frame.size.width + _songerNameLabel.frame.origin.x, _songerNameLabel.frame.origin.y, 30, 30);
    self.songsListenLabel.frame = CGRectMake(_titleImageView.frame.size.width + _titleImageView.frame.origin.x, _titleImageView.frame.origin.y, self.frame.size.width - _titleImageView.frame.size.width - _titleImageView.frame.origin.x, 30);
}

- (void)setListen:(ListenDataSongsModel *)listen
{
    if (_listen != listen) {
        [_listen release];
        _listen = [listen retain];
    }
    _titleLabel.text = listen.name;
    _songerNameLabel.text = listen.singerName;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
